cities <-tribble(~ city, ~lat, ~long, ~population,"Vienna", 48.2083, 16.3725, 1973403,"Graz", 47.0708, 15.4386, 289440,"Linz", 48.3058, 14.2864, 210165,"Salzburg", 47.8000, 13.0450, 155021,"Innsbruck", 47.2683, 11.3933, 131961,"Klagenfurt", 46.6167, 14.3000, 101403) %>%mutate(ratio = population/sum(population))# feature engineer# need temperature, direct radiation, holidays, meteodata <- cities %>%mutate(data =pmap(., function(lat, long, ...) {weather_history(location =c(lat, long),hourly =c("temperature_2m", "direct_radiation", "relative_humidity_2m"),start =min(date(austria$time)),end =max(date(austria$time)),timezone ="UTC" ) }) ) %>%unnest(data)meteo_weighted <- meteodata %>%select(datetime, hourly_direct_radiation, hourly_temperature_2m, hourly_relative_humidity_2m, city, ratio) %>%pivot_longer(-c(datetime, city, ratio)) %>%group_by(datetime, name) %>%summarise(value =weighted.mean(x = value, w = ratio) )# population weightedmeteo_population_weighted <- meteo_weighted %>%pivot_wider(names_from = name, values_from = value)austria_comb <- austria %>%left_join(meteo_population_weighted, by =c("time"="datetime")) %>%fill(c(where(is.numeric)),.direction ="down")holidays <-tribble(~ date, ~description,"01 January 2022", "New Year's Day","06 January 2022", "Epiphany","18 April 2022", "Easter Monday","01 May 2022", "Labour Day","26 May 2022", "Ascension Day","06 June 2022", "Whit Monday","15 August 2022", "Assumption of the Virgin Mary","26 October 2022", "Austrian National Holiday","01 November 2022", "All Saints' Day","08 December 2022", "Immaculate Conception","24 December 2022", "Christmas Eve","25 December 2022", "Christmas Day","26 December 2022", "Boxing Day","31 December 2022", "New Year","01 January 2023", "New Year's Day","06 January 2023", "Epiphany","10 April 2023", "Easter Monday","01 May 2023", "Labour Day","18 May 2023", "Ascension Day","29 May 2023", "Whit Monday","15 August 2023", "Assumption of the Virgin Mary","26 October 2023", "Austrian National Holiday","01 November 2023", "All Saints' Day","08 December 2023", "Immaculate Conception","24 December 2023", "Christmas Eve","25 December 2023", "Christmas Day","26 December 2023", "Boxing Day","31 December 2023", "New Year") %>%mutate(date =dmy(date))daily_tbl<- austria_comb %>%group_by(date =date(time)) %>%summarise(across(where(is.numeric), mean)) %>%mutate(dow =wday(date, label =TRUE), dow =if_else(dow %in%c("Tue", "Thu", "Wed"), "trittico", dow),dow =as.character(dow),dow =if_else(date %in% holidays$date, "holiday", dow) ) p1 <- daily_tbl %>%ggplot(aes(actual_load, hourly_temperature_2m, color =as.factor(dow)))+geom_point()+coord_flip()+theme_bw()+ggtitle(label ="population weighted temperature vs load")plotly::ggplotly(p1)
Code
p2 <- daily_tbl %>%ggplot(aes(actual_load, hourly_direct_radiation, color =as.factor(dow)))+geom_point()+coord_flip()+theme_bw() +ggtitle(label ="population weighted solar radiation vs load")plotly::ggplotly(p2)
Code
p3 <- daily_tbl %>%ggplot(aes(actual_load, hourly_relative_humidity_2m, color =as.factor(dow)))+geom_point()+coord_flip()+theme_bw() +ggtitle(label ="population weighted humidity vs load")plotly::ggplotly(p3)
Comment
From the last plots we can see that temperature and solar radiation are strong predictors of the load. There is no big reaction to very high temperatures in Austria, differently from what i would have expected. Solar radiation also being a strong predictor suggests there is load masking going on to some degree.